<template>
	<view class="page-box">
		<view class="page-title">
			<view class="title-text-name">
				项目名称
			</view>
			<view class="title-text">{{options.projectName}}</view>
		</view>
		<form @submit="handleSubmit">
			<view class="page-form">
				<view class="form-item">
					<view class="uni-title uni-common-pl">批示</view>
					<view class="uni-textarea">
						<textarea class="style-text"  auto-height placeholder="请填批示内容" name="OTHER" v-model="data.OTHER"/>
					</view>
				</view>
			</view>
			<view class="fixed-action-bar">
				<view class="item">
					<button class="btn-box" form-type="submit">
						<image src="../../static/images/icon_save.png" mode="widthFix" class="icon"></image>
						<text class="text-edit">提交批示</text>
					</button>
				</view>
				<view class="item" @click="handleCancel">
					<view class="btn-box">
						<image src="../../static/images/icon_next.png" mode="widthFix" class="icon"></image>
						<text class="text-delete">返回取消</text>
					</view>
				</view>
			</view>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:{
		
				},
				options:{}
			}
		},
		methods: {
			bindTextAreaBlur(e) {
				console.log(e.detail.value)
			},
			async handleSubmit(e){
				const formData = {...e.detail.value};
				uni.showLoading()
				const ret = await this.$req({
					url:'bus/opinion/save.do',
					data:{
						OPINION:formData.OTHER,
						isadding: true,									
						PROJ_ID: this.options.projectId
					}
				})
				uni.hideLoading()
				if(ret.data.success){
					uni.showToast({
						title:'提交批示成功',
						icon:'none'
					})
					uni.navigateBack()
					// uni.switchTab({
					//     url: '/pages/myProject/myProject',
					//     success(){
					//         let page = getCurrentPages().pop(); //跳转页面成功之后
					//         if (!page) return; 
					//             page.onLoad(); //如果页面存在，则重新刷新页面
					//         }
					// });
				} else {
					uni.showToast({
						title:ret.data.messages[0].content,
						icon:'none'
					})
				}
			},
			handleCancel(){
				uni.navigateBack({
				})
			},
		},
		onLoad(options){
			this.options = options;
			console.log('options值为',options)
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #e9f0f2;
	}
	.page-box{
		margin: 20rpx 30rpx;
		padding: 38rpx 30rpx;
		width: 690rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		.page-title{
			display: flex;
			justify-content: space-between;
			// align-items: center;
			.title-text{
				text-align: left;
				width: 430rpx;
				font-family: Alibaba-PuHuiTi-B;
				font-weight: 700;
				font-size: 30rpx;
				color: #414a5d;
			}
			.title-text-name{
				width: 130rpx;
				font-size: 26rpx;
				color: #414a5d;
			}
			.title-icon{
				display: flex;
				align-items: center;
				image{
					width: 27rpx;
					height: 27rpx;
					margin-right: 10rpx;
				}
				.icon-right{
					font-size: 24rpx;
					line-height: 34rpx;
					color: #0099cc;
				}
			}
		}
		.page-tag{
			width: 120rpx;
			height: 30rpx;
			margin-top: 14rpx;
			font-size: 24rpx;
			line-height: 30rpx;
			text-align: center;
			background-color: #00ac0c;
			border-radius: 4rpx;
			color: #FFFFFF;
		}
		.page-form{
			margin-top: 32rpx;
			// padding: 0 40rpx;
			.form-item{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				margin-bottom: 30rpx;
				min-height: 432rpx;
				.uni-title{
					width: 130rpx;
					font-size: 26rpx;
					color: #414a5d;
				}
				.uni-textarea{
					width: 430rpx !important;
					font-size: 26rpx;
					line-height: 36rpx;
					border-bottom: 2rpx solid #dce4e6;
					color: #808080;
					/deep/.uni-textarea-wrapper{
						width: 430rpx !important;
					}
				}
				.style-text{
					width: 430rpx !important;
					font-size: 26rpx;
					line-height: 34rpx;
				}
			}
		}
		
	}
	
	.fixed-action-bar{
		width: 100%;
		display: flex;
		height: 70rpx;
		align-items: center;
		background: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 999;
		.item{
			width: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
			
		}
		.icon{
			width: 30rpx;
		}
		.btn-box{
			width: 140rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 70rpx;
		}
		.text-edit{
			font-size: 24rpx;
			color: #0099cc;
			line-height: 70rpx;
		}
		.text-delete{
			font-size: 24rpx;
			color: #cc3357;
			line-height: 70rpx;
		}
	}
</style>
